import AdminMain from '@/views/admin/Main'
import HomeMain from '@/views/home/Main'

function loadView (view) {
  return () => import(/* webpackChunkName: "view-[request]" */ `@/views/${view}.vue`)
  // return () => import(/* webpackChunkName: "routes" */ `@/views/${view}.vue`)
}
export default [{
  path: '*',
  meta: {
    public: true
  },
  redirect: {
    path: '/404'
  }
}, {
  path: '/404',
  name: '404',
  meta: {
    public: true
  },
  component: loadView('errors/404')
}, {
  path: '/403',
  name: '403',
  meta: {
    public: true
  },
  component: loadView('errors/403')
}, {
  path: '/500',
  name: '500',
  meta: {
    public: true
  },
  component: loadView('errors/500')
}, {
  path: '/close',
  name: 'close',
  meta: {
    public: true
  },
  component: loadView('errors/close')
},
{
  path: '/',
  name: 'home',
  component: HomeMain,
  meta: {
    requiresAuth: false,
    handleClose: true
  },
  children: [{
    path: '/',
    name: 'homepage',
    component: loadView('home/Home'),
    meta: {
      handleClose: true
    }
  }, {
    path: 'archive',
    name: 'archive',
    component: loadView('home/Archive')
  },
  {
    path: 'article/:id',
    name: 'article',
    component: loadView('home/Article')
  }, {
    path: 'page/:id',
    name: 'page',
    component: loadView('home/Page')
  },
  {
    path: 'tag/:id',
    name: 'tag',
    component: loadView('home/Tag')
  },
  {
    path: 'node/:id',
    name: 'node',
    component: loadView('home/Node')
  }, {
    path: 'messages',
    name: 'messages',
    component: loadView('home/Messages')
  }
  ]
},
{
  path: '/login',
  name: 'login',
  component: loadView('Login')
},
{
  path: '/admin',
  name: 'admin',
  component: AdminMain,
  meta: {
    requiresAuth: true
  },
  redirect: {
    name: 'dashboard'
  },
  children: [{
    path: 'dashboard',
    name: 'dashboard',
    meta: {
      name: '控制台',
      breadcrumb: false
    },
    component: loadView('admin/Dashboard')
  },
  {
    path: 'config/site',
    name: 'config_site',
    meta: {
      name: '配置管理',
      breadcrumb: true
    },
    component: loadView('admin/config/site')
  },
  {
    path: 'config/menu',
    name: 'config_menu',
    meta: {
      name: '菜单管理',
      breadcrumb: true
    },
    component: loadView('admin/config/menu')
  },
  {
    path: 'manage/tag',
    name: 'tag_manage',
    meta: {
      name: '标签管理',
      breadcrumb: true
    },
    component: loadView('admin/tag/list')
  },
  {
    path: 'manage/node',
    name: 'node_manage',
    meta: {
      name: '栏目管理',
      breadcrumb: true
    },
    component: loadView('admin/node/list')
  }, {
    path: 'manage/article',
    name: 'article_manage',
    meta: {
      name: '文章管理',
      breadcrumb: true
    },
    component: loadView('admin/article/list')
  }, {
    path: 'article/create',
    name: 'article_create',
    meta: {
      name: '新建文章',
      breadcrumb: true
    },
    component: loadView('admin/article/create')
  },
  {
    path: 'manage/page',
    name: 'page_manage',
    meta: {
      name: '单页管理',
      breadcrumb: true
    },
    component: loadView('admin/page/list')
  }, {
    path: 'manage/trash',
    name: 'trash_manage',
    meta: {
      name: '回收站',
      breadcrumb: true
    },
    component: loadView('admin/trash/list')
  }, {
    path: 'other/link',
    name: 'link_manage',
    meta: {
      name: '外链管理',
      breadcrumb: true
    },
    component: loadView('admin/link/list')
  }, {
    path: 'permission/user',
    name: 'user_manage',
    meta: {
      name: '用户管理',
      breadcrumb: true
    },
    component: loadView('admin/article/list')
  }, {
    path: 'permission/role',
    name: 'role_manage',
    meta: {
      name: '角色管理',
      breadcrumb: true
    },
    component: loadView('admin/article/list')
  }, {
    path: 'permission/all',
    name: 'permission_manage',
    meta: {
      name: '权限管理',
      breadcrumb: true
    },
    component: loadView('admin/article/list')
  }, {
    path: 'logs',
    name: 'logs_manage',
    meta: {
      name: '操作日志',
      breadcrumb: true
    },
    component: loadView('admin/article/list')
  }, {
    path: 'image_hosting',
    name: 'image_hosting',
    meta: {
      name: '图床',
      breadcrumb: true
    },
    component: loadView('admin/common/ImageHosting')
  }
  ]
}
]
